<div class="container">
    <email-settings-warning function="invite emails"></email-settings-warning>

    <users-nav></users-nav>

    <h2>{{user.name}}</h2>

    <tabset>
        <tab heading="Profile" active="tabs['profile']" select="setTab('profile')">
            <p>
                <img src="{{user.gravatar_url}}"/>
            </p>

            <p>
                <strong>{{user.name}}</strong>
            </p>

            <p>
                {{user.email}}
            </p>
            <div ng-if="currentUser.isAdmin">
                <hr/>
                <button class="btn btn-default" ng-click="sendPasswordReset()" ng-disabled="disablePasswordResetButton">Send Password Reset Email</button>
            </div>
        </tab>
        <tab heading="API Key" ng-if="user.api_key" active="tabs['apiKey']" select="setTab('apiKey')">
            API Key:
            <input type="text" value="{{user.api_key}}" size="44" readonly/>
        </tab>
        <tab heading="Settings" ng-if="showSettings" active="tabs['settings']" select="setTab('settings')">
            <div class="col-md-6">
                <form class="form" name="userSettingsForm" ng-submit="updateUser(userSettingsForm)" novalidate>
                    <div class="form-group required" show-errors>
                        <label class="control-label">Name</label>
                        <input name="name" type="text" class="form-control" ng-model="user.name" required/>
                        <input-errors errors="userSettingsForm.name.$error"/>
                    </div>
                    <div class="form-group required" show-errors>
                        <label class="control-label">Email</label>
                        <input name="email" type="email" class="form-control" ng-model="user.email" required/>
                        <input-errors errors="userSettingsForm.email.$error"/>
                    </div>
                    <div class="form-group">
                        <button class="btn btn-primary">Save</button>
                    </div>
                </form>
            </div>
        </tab>
        <tab heading="Password" ng-if="showPasswordSettings" active="tabs['password']" select="setTab('password')">
            <div class="col-md-6">
                <form class="form" name="userPasswordForm" ng-submit="savePassword(userPasswordForm)" novalidate>
                    <div class="form-group required" show-errors>
                        <label class="control-label">Current Password</label>
                        <input name="currentPassword" class="form-control" type="password" ng-model="password.current" required/>
                        <input-errors name="Password" errors="userPasswordForm.currentPassword.$error"/>
                    </div>
                    <div class="form-group required" show-errors>
                        <label class="control-label">New Password</label>
                        <input name="newPassword" class="form-control" type="password" ng-model="password.new" ng-minlength="6" required/>
                        <input-errors name="Password" errors="userPasswordForm.newPassword.$error"/>
                    </div>
                    <div class="form-group required" show-errors>
                        <label class="control-label">Repeat New Password</label>
                        <input name="passwordRepeat" class="form-control" type="password" ng-model="password.newRepeat" compare-to="password.new"/>
                        <span class="help-block error" ng-if="userPasswordForm.passwordRepeat.$error.compareTo">Passwords don't match.</span>
                    </div>
                    <div class="form-group">
                        <button class="btn btn-primary">Save</button>
                    </div>
                </form>
            </div>
        </tab>
    </tabset>

</div>
